Beamline simulations using monochromators with high d-spacing crystals

A method is introduced for representation of arbitrary crystals, numerical calculation treatment and ray-tracing simulation, and upgrading the tools in the OASYS suit; the upgraded tools are particularly helpful for very complicated crystals constituting charged atoms arranged in any crystalline structure and including isotropic or anisotropic temperature factors. The new open source software tools developed here are available for supporting accurate calculations in the design and optimization of new X-ray monochromators.


Introduction
X-ray monochromators use crystals that must fulfill many requirements: they must have high perfection (no dislocations, low mosaicity); be available as large, single crystals; have high resistance to radiation damage; and have high thermal conductivity. The ubiquitous material for X-ray monochromators and analyzers is silicon; crystals of silicon are available in large sizes and with high perfection. Indeed, silicon is the most perfect large crystal in the world. Germanium, with slightly higher cell parameters, also forms a highly perfect crystal but is more expensive. Synthetic diamond is also used in X-ray monochromators because of its low absorption and exceptional thermal conductivity. These are cubic face-centred-cubic (f.c.c.) crystals, and the lower nonforbidden reflection is 111, which is indeed the most used reflection in synchrotron monochromators. With a d-spacing of 3.135 Å , Si 111 is not very effective for large Bragg angles (3 keV corresponds to 41.2 and the minimum energy attained is 1.977 keV at normal incidence). Therefore, other crystals with large cell parameters must be investigated for applications using tender X-rays. Many natural crystals have been proposed. An exhaustive list of crystals with larger d-spacing is given by Underwood (2001). Databases such as DABAX (Sanchez del Rio, 2011a) and Stepanov's X-ray server (Stepanov, 2004) contain long lists of crystal structures that can be used in X-ray monochromators. We have compiled in Table 1 a list of crystal reflections with large d-spacing, including useful energy range, Darwin width ( d ), relative energy resolution (ÁE/E) and peak reflectivity (R).
Despite such a long list, it is difficult to acquire a suitable crystal for the tender X-ray regime. In particular, organic crystals cannot withstand high heat loads, and many natural crystals cannot be found with high perfection in the large size needed for monochromators. Synthetic crystals such as synthetic quartz (Cerino et al., 1980;Wong et al., 1999;Ohta et al., 1986) and sapphire (Shvyd'ko et al., 2017;Said et al., 2020) are nowadays obtained with quality and size suitable for X-ray applications. However, quartz degrades very quickly under exposure to intense synchrotron radiation. Sapphire is better (Gog et al., 2018), nevertheless still sensitive enough to radiation damage. Diamond has exceptional resistance that makes it appropriate for hard X-rays. The ongoing search for good crystals must be accompanied, and in many cases driven, by computer simulations of the theoretical reflectivity profiles of the crystals, to simulate by ray-tracing the whole monochromator embedded in a synchrotron beamline. Computer tools for such simulations are not easy to find, despite the already long list of available crystals in tools like OASYS (Rebuffi & Sanchez del Rio, 2017), or Sergei Stepanov's X-ray server (Stepanov, 2004).
One crystal proposed and used in the tender X-ray range is YB 66 . The crystal structure is face-centered cubic with a = 23.440 Å (Richards & Kasper, 1969). The material is refractory and has a melting point of 2100 C. It is thermally stable and can resist severe radiation and high heat load. The crystal can be fabricated with high quality (Tanaka, 2010) and has been successfully applied in double-crystal monochromators (DCMs) in the tender energy regime (Smith et al., 1998;Rek et al., 1993;Wong et al., 1990;Ohta et al., 1986;Kitamura & Fukushima, 2004;Wong et al., 1995).
About 14 years ago, at the XAFCA beamline at Singapore Synchrotron  Table 1 Crystals with large 2d-spacings with the usable photon energy range, Darwin width ( d ), energy resolution (ÁE/E) and peak reflectivity (R). The lowest energy corresponds to normal incidence. d and R and ÁE/E = d cot( B ), where B is the Bragg angle, are calculated at 1.1 times the lowest energy. Calculations are performed with code developed in this work scanning the crystal structures available in DABAX (source code 0) and Stepanov's X-ray server (source code 1). Light Source (Yu & Moser, 2008) working in a photon energy interval of 0.85-12.8 keV, we adopted a sagittalfocusing DCM with Si (111) crystals to cover the energy range 2.15-12.8 keV. However, for energies below 3 keV in the original optical design, we looked at three crystals, InSn (111), beryl (10 " 1 10) and YB 66 , to cover the lower-energy range. It was difficult and expensive to acquire large-size YB 66 crystal wafers, and beryl has a strong aluminium absorption edge which is a disadvantage for the study of aluminium catalysis. A KTP (011) crystal pair was chosen in the final beamline. Ray-tracing calculations were performed using SHADOW (Cerrina, 1984), modified to account for crystal reflectivity interpolated from a data file, in this way inhibiting the internal crystal reflectivity calculation during ray tracing.
In recent years, larger YB-like crystals have been produced (Tanaka, 2020) at a lower cost, therefore interest in this crystal has renewed. However, no recent use of a YB 66 crystal in a DCM beamline has been reported. One reason may be that, for high-brilliance insertion-device synchrotron sources, soft X-ray grating monochromators are now used up to 2.5 keV, close to the upper limit of tender X-rays, something that was impossible in the past (Hawthorn et al., 2011;McChesney et al., 2014;Tang et al., 2019). In terms of the resolution and reflectivity, YB 66 is still attractive. The YB 66 resolving power (E/ÁE) is $ 23 000 for 004 and 122 000 for 006 (from Table 1), with peak reflectivity of 15% and 10%, respectively. As compared with grating monochromators, the resolution can be considered as 'high', and the peak reflectivity is also of the order of the efficiency obtained by good gratings. In theory, the performance obtained by a monochromator with an ideal YB 66 crystal is at least as good as that using gratings. The use of crystals is more advantageous for large sources (wigglers or bending magnets), as gratings require a clean focusing to become effective. However, grating monochromators can easily tune the resolution by playing with the slit aperture and customizing ruling values.
To prepare for possible upgrades of synchrotron beamlines and the use of YB 66 and other complex crystals, we have upgraded the ray-tracing code SHADOW3 (Sanchez del Rio, 2011b) and other tools in OASYS to include, in a seamless way, any crystal structure. The code algorithms and modifications are presented in this work. It is now possible with the ShadowOUI (Rebuffi & Sanchez del Río, 2016) add-on of OASYS (that interfaces SHADOW) to ray-trace YB 66 crystals and any other crystal of interest for an X-ray monochromator or analyser.
2. Calculation of the structure factor of any crystal structure 2.1. Structure factor of a crystal The structure factor of a crystal is where h, k, l are Miller indices, C j is the occupancy factor, T j is the Debye-Waller or temperature factor, f j = (f 0 + f 0 + if 00 ) j are atomic scattering factors, and x j , y j , z j are fractional coordinates of the atoms in the unit cell. The sub-index refers to the jth atom in the unit cell, and the sum extends over the n atoms of the unit cell.
To compute the structure factor using equation (1) for a particular structure we need libraries and methods to access: (1) The information from the crystal structure itself, meaning a list of all atoms in the unit cell, as well as the cell parameters (a, b, c, , , ). Each atomic center in this list must contain the fractional coordinates, the nature of the center (its atomic number Z) and also the ionic charge and fractional occupation. Moreover, other information could be added to compute the temperature factor, as described below. Note that the summation goes over the n atoms in the unit cell. In crystallography, the list of all atoms is created by applying the symmetry operations from the space symmetry group to a reduced number of atoms (the asymmetric unit).  (2) The atomic scattering factors. The elastic scattering f 0 depends to a good approximation only on q = (sin )/, with the grazing incidence angle and the photon wavelength. The so-called 'anomalous' scattering factors f 0 and f 00 depend on the nature of the atom and on the photon wavelength.
Although the structure factor can be efficiently calculated by a single piece of code, it requires quick access to data usually stored in libraries or databases. Four sources of information are needed: unit-cell information, f 0 values, and the anomalous scattering values f 0 and f 00 . The ab initio calculation of the scattering factors can only be performed using complex quantum mechanics calculations, and it is out of the scope of most crystallography codes. Tabulated data from some references may be used, usually linking the code to available data files or databases. This linkage makes the software structure complicated and reduces portability. This is why in the ray-tracing code SHADOW (and also in OASYS crystal tools) the calculation is performed in two steps: (i) a preprocessor code that accesses necessary data from databases and creates a 'crystal material file' with the basic ingredients needed to build the structure factor, and (ii) the calculation of the structure factor in the SHADOW kernel using only the information in the preprocessor file, without any further link to databases.
The first version of SHADOW used internal tabulations to retrieve the f 0 and f 00 values, but did not provide any f 0 data. The old SHADOW interface in XOP (Sanchez del Rio, 2011a) took the data from DABAX, an ad hoc compiled collection of material data, available from http://ftp.esrf.eu/pub/scisoft/ DabaxFiles, where several tabulations for the same kind of data (e.g. f 0 ) coexist. The OASYS package uses xraylib (Schoonjans et al., 2011;Schoonjans, 2021) which is a compiled library that allows fast access of a large collection of X-ray data. OASYS can also use DABAX where we included the new data needed for this work.

Ingredients for computing the structure factor
The structure factor F(h,k, l) [equation (1)] comes from the summation of all waves scattered by the n atoms in the unit cell in the direction defined by the Miller indices hkl. Each atom j contributes to a wave whose amplitude is proportional to the atomic scattering factor f j , that measures the X-ray scattering power of each atom. Its main component is the elastic scattering factor f 0 . The scattered power is maximum in the direction of the incident X-rays, and decreases as a function of the angle of departure. It is proportional to the number of electrons in the atom. In 'electron units', f 0 is equal to Z at the zero scattering angle ( = 0 ), and reduces to almost zero at values of q = (sin )/ larger than about 2 Å À1 (2 is the angle between incident and scattered X-ray beam with wavelength of ). This dependency is tabulated after some theoretical calculations and can be parametrized. Cromer & Mann (1968) proposed a sum of Gaussians parametrization with nine coefficients, with Nc = 4. The nine coefficients (a 1 -a 4 , c, b 1 -b 4 ) are obtained by fitting tabulations of f 0 computed using theoretical models. A common tabulation is shown in International Tables of Crystallography, and includes all neutral atoms and a few ionic states. Waasmaier & Kierfel (1995) extended the number of coefficients to 11 to fit data up to q max ' 6 Å À1 . In OASYS, the theoretical calculation from Kissel (2000) is fitted to obtain a list of 11 coefficients for all neutral atoms. Most typical crystals used in monochromators are covalent crystals so f 0 data for neutral atoms is enough. However, data for ions with integer or fractional charge is sometimes needed. For example, for YB 66 the calculation of form factors f 0 requires the ionic states 'Y 3+ ' and 'B À. ' (the dot indicates a tiny negative charge in the B atoms. We follow the formula of Higashi et al. (1997), so the charges removed from the neutral Y atoms are equally allocated among all boron atoms. Some f 0 coefficients for ionic states are available in International Tables for X-ray Crystallography (Ibers & Hamilton, 1974) (hereafter called ITC).
For some particular ionic states, like in the case of Y 3+ (needed in the YB 66 crystal), the f 0 data are found in the ITC tabulation. However, in most cases, such as for the tiny charge of B in YB 66 , there are no tabulated data for f 0 . Values of some ionic states of B, such as B 3+ , are found in a table in ITC (p. 202). We fitted B 3+ data to obtain the nine parameters that were added to the DABAX file f0 InterTables:dat that contains the ITC tabulation. DABAX is incorporated into our tools for retrieving the nine parameters of the f 0 coefficients for both neutral and ionic atoms. In cases of ions with fractional charge, like B À0.0455 required in the YB 66 crystal, the nine coefficients for parametrizing f 0 are calculated by interpolating the data from two entries in the table with different charges.
Using the form factors data f 0 (B), f 0 (B 3+ ), f 0 (Y 3+ ) from this reference, and assuming 'B À. ' carries a negative charge of = 0.0455, the form factors for 'B À. ' can be calculated as a linear interpolation, A comparison plot of f 0 versus q for neutral atoms of Y and B is shown in Fig. 1. It shows good agreement between xraylib and DABAX for the neutral species, but the new ionic states are only available from DABAX.
The intense elastic scattering f 0 can be reduced if the incident X-ray radiation has a frequency close to the natural oscillation frequency of the electrons of a given atom. This effect is called anomalous dispersion (although there is nothing 'anomalous') and is represented by f 0 and f 00 , the real and imaginary components, respectively, of the anomalous fraction of the atomic scattering factor. These are functions of the photon energy. Anomalous scattering factors used in most software packages come from old calculations using quantum electrodynamics data (EPDL97, https://www-nds.iaea.org/ epdl97/), mixed experimentally evaluated data (Henke et al., research papers 1993), or a combination of them. In the past, SHADOW used hybrid data from Henke et al. (1993) (up to 30 keV) and Cromer (1983). DABAX files contain many tabulations available in the literature. The library xraylib, used by default in OASYS, accesses a selected tabulation of data as described by Schoonjans et al. (2011). The inclusion of anomalous scattering factors in calculations of crystal diffraction profiles using the dynamical theory of diffraction is essential, as it contributes to the peak intensity.
The list of atoms in the unit cell is tabulated in the DABAX file crystals:dat. The same data are also integrated in xraylib. We added the new entry YB 66 in DABAX, with information on the composition of the crystal unit cell.

Anisotropic temperature factors
Displacement of atoms from their mean positions in the crystal structure weakens the scattered X-ray intensity. A Debye-Waller factor takes this effect into account in the structure analysis. Lonsdale & Grenville-Wells (1956) observed that Debye-Waller factors (also called temperature factors) for most crystals are indeed anisotropic. In addition, thermal movement from the same atoms may be different in different atomic sites (as shown in Table 2). In most cases, atoms belonging to the same group of prototypical atoms have different temperature factors. The anisotropic temperature factors of 14 symmetric sites for YB 66 are plotted in Fig. 2; one can see that the temperature factors for boron atoms are different in 13 atomic sites, except sites B6 and B7. The anisotropic factors for all symmetric sites are necessarily included for accurate crystal structure calculations; therefore the list of prototypical atoms must also reflect the site information from the temperature factors.
To describe the anisotropic temperature factor when the atomic displacement follows a tri-variate Gaussian probability distribution function (as usually accepted), six coefficients, ij (i, j = 1, 2, 3), are needed [equation (21)

Figure 2
Anisotropic temperature factor of 14 symmetric sites for YB 66 (400), each site labeled with atomic name and site index. The temperature factors vary on symmetric sites for 13 boron atoms, except B6 and B7 for which they are the same.
In Table 2, we give an example input of anisotropic temperature data for YB 66 (Richards & Kasper, 1969). Boron atoms occupy 13 symmetric sites, each having different anisotropic temperature factors, and yttrium atoms occupy a single site, with equivalent temperature factors. The ij coefficients are always far less than 1 for an anisotropic temperature factor. Once 11 is set to 1, the ij coefficients are for a different notation, with only 22 representing an isotropic B eq factor, while the coefficients in other columns are discarded (all set to zero). The temperature-factor data for any crystal can be easily defined accordingly. If no input line beginning with #UANISO COFF is found in the crystal file, the default scale temperature factor is used.
In the calculations, two temperature factors are implemented -the anisotropic [equation (4)] and the isotropic temperature factors. In the last case, the displacement amplitudes are equivalent for all directions, and the temperature factor depends on the isotropic B eq factor (Trueblood et al., 1996;Higashi et al., 1997), where B eq ¼ 4 3 a 2 11 þ b 2 22 þ c 2 33 À Á : When calculating the anisotropic temperature factor for YB 66 400, according to the formula, only 11 contributes to the temperature factor, and there are two identical pairs of 11 ; therefore we only have 12 different anisotropic temperature factors. For isotropic factor B eq , there are two identical factors for sites B2 and B7, so there are 13 different temperature factors (see Fig. 2). For some crystal structures, for instance some of the YB 66 variants in Higashi et al. (1997), only B eq factors are given. We handle such cases using the #UANISO COFF coefficients, with the convention of setting 11 to a number equal to or greater than one, and setting 22 to B eq .

The new crystal preprocessor for OASYS and SHADOW
The preprocessor file in SHADOW and CRYSTAL contains the elements of the structure factor [equation (1)]. The idea is to group atoms that are identical in all parameters except in (x, y, z) in a single 'prototypical' atom. With this, the number of terms in the sum is reduced and the calculation is faster.
The new code bragg_calc2 is used for generating the crystal material file used in both SHADOW and OASYS (CRYSTAL and FH widgets). This code can use two libraries for material constants (xraylib and DABAX), at the users' choice. When calculating YB 66 , DABAX is the only option, as it was upgraded with its crystal unit-cell structure (in the file crystals:dat) and f 0 ionic states (in the file f0 InterTables:dat).
The format of the new crystal material file evolved from the original one to minimize changes of source code; the old and new formats are shown in Figs. 3(a) and 3(b), respectively. In the old format preprocessor file, a maximum of two kinds of atoms and two symmetric sites can be input, and a maximum of eight atoms in a Bravais unit cell. The first item, named i LATTICE in the first line, identifies the file format. Integer values of 0 to 5 denote this file in the old format containing data for the Bravais lattice types of zinc blende, rock salt, simple f.c.c. and CsCl structure, and two hexagonal (closepacked structure and graphite structure), respectively. RN and D SPACE are the product of the inverse of the volume of a unit cell and classical electron radius, and the distance between crystalline planes, respectively.
In the new file format, there are three main differences for crystal input. First, there is no limit on the number of prototypical or site-atoms used; each one will have corresponding values of G and G BAR (complex conjugate of G) geometrical factors [corresponding to the exponential in equation (1)], and coefficients for f 0 . Second, the atoms in a crystal can carry integer or fractional charges, ATOM A and ATOM B in Fig. 3(a). The integer atomic numbers of the constituent atoms are replaced by a float number of scattering electrons [atomic number plus ionic charge Z1, Z2, Zn in Fig. 3(b)]. Third, temperature factors are included for different symmetric sites.
In the new file format, each prototypical atom has a different identifier. This contains the atomic number, site occupation, fractional charge and temperature factor. Two atoms in the unit cell belonging to the same prototype only differ in the coordinates. Therefore, equation (1) becomes a sum to M prototypical atoms, with G a geometrical factor that contains the sum of atoms belonging to each prototypical group, The new file format can safely replace the old file format without introducing errors for any crystal allowed in the old SHADOW file, because the ray-tracing calculated results are  The original (a) and new (b) formats of a SHADOW preprocessor file.
The new format file includes a comment explanation following each line of parameters. The index or the prototypical atoms goes from 1 to NBATOM, and ncol i represents the number of f 0 coefficients for a particular prototypical atom (it must be an odd number, typically 9 or 11).
identical for the existing crystals represented by the two formats as demonstrated in Section 4.

New crystals in OASYS widgets
In the OASYS suite, the widgets that perform crystal calculations are FH and CRYSTAL in the XOPPY add-on, and BRAGG pre-processor in the ShadowOUI add-on. FH and CRYSTAL widgets are used for calculating crystal structure parameters, for instance, the structure factor, Darwin width, Bragg angle, etc. and the X-ray reflectivity for crystals. Previously these applications accepted crystals composed of neutral atoms with single scale temperature factors for all atomic sites. A new software component bragg calc2 has been introduced to calculate arbitrary crystals including charged atoms, and isotropic or anisotropic temperature factors in different sites. Fig. 4 shows the reflectivity of mica 111 at 8 keV calculated with the new bragg calc2 and compared with calculations using Stepanov's X-ray server. Both curves are in good agreement.
The SHADOW preprocessor widget BRAGG is used for creating the crystal input file for SHADOW. This widget has been updated to use bragg calc2 code for new crystals such as YB 66 .

Validation of the model for the YB 66 crystal
To validate the generated model (lattice constants, atomic coordinators list and temperature factor, etc.) of YB 66 crystal insertion in the file crystals:dat for the OASYS suite, the structure factors F(0,0,0) and F(H,K,L) are calculated with the updated FH widget under XOPPY Optics in the OASYS suite (see Fig. 5). Some calculated structure factors for the index planes with practical synchrotron radiation applications are tabulated in Table 3 for comparison with data from Richards & Kasper (1969), who tabulated | F| CALC (calculated) and |F| OBS (measured) with Cu K radiation ($ 8040 eV). A photon energy of 8040 eV was used in our calculations. The calculated F(0,0,0) of 8846 is in agreement with the calculated value of 8841 by Richard & Kaspar (1969). However, to make the overall comparison consistent, the F(H,K,L) values by Richard & Kaspar (1969) must be multiplied by four, because their calculation included the factor x ð1=4Þ for YB 66 (Tanaka, 2020).

Diffraction profiles
The calculated structure factors for YB 66 are compared in Table 3 with those of Richards & Kasper (1969). The updated CRYSTAL widget can calculate the reflectivity for an arbitrary crystal. The reflectivity plot of YB 66 004 (see Fig. 6  Comparison of crystal profile calculations of mica 111 at 8 keV using the new code (circles) and Stepanov's X-ray server (solid line). Table 3 Comparison of calculated structures factors with those of Richards & Kasper (1969) for YB 66 . F(0,0,0) = 8846. | F | are structure factor calculations in this text. | F | CALC and | F | OBS are calculations and observations, respectively, taken from Richards & Kasper (1969).

Demonstration of ray-tracing simulations for YB 66 crystal
The SHADOW code is a well known ray-tracing engine for beamline design in the synchrotron radiation community. Almost all current beamlines benefitted from the help of SHADOW. We use SHADOW3 code interfaced in the ShadowOUI add-on of OASYS to demonstrate the ray-tracing results of a DCM with neutral atomic crystal and ionic atomic crystals represented by new SHADOW preprocessor files, in comparison with the data in the references. Both preprocessor files are created with the updated BRAGG widget.
To check the consistency of the modifications included in SHADOW, we performed ray tracing of a DCM with InSb (111) crystal pair with the old and new preprocessor file formats at a photon energy around 1.8 keV. The results [Figs. 7(a) and 7(b)] show an excellent agreement in reflectance profile and full width at half-maximum (FWHM).
A second test aimed to compare simulations for beryl (Al 2 Si 6 Be 3 O 18 ) with bibliographic data. Fig. 7(c) shows the ray-tracing result of a single-crystal reflection for beryl ð10 " 1 10Þ. This crystal structure includes four different elements and was not possible to simulate with the old SHADOW. The system comprises a point source with angular divergence of 0.3 mrad (FWHM) positioned 2 m upstream of a beryl crystal. Ray tracing gives a resolution of 0.72 eV (r.m.s.), which would correspond to a FWHM of 1.7 eV if the profile was supposed to follow a Gaussian. This is in good agreement with the measurement result of 1.6 eV FWHM [see Fig. 5 Wong et al. (1999)]. Moreover, the peak reflectivity of 15.6% [see Fig. 7(c)] quantitatively agrees with the measurement [12.8% in Wong et al. (1999), Fig. 5(a)]. Here, the angular divergence has been intentionally set to 130 mrad RMS because this information is not found in that reference.
The last simulations concern YB 66 , and are also benchmarked against published data. The DCM of YB 66 (004) crystals has important glitches around 1385.6 eV and 1438 eV (Smith et al., 1998;Wong et al., 1999). There is an increase of intensity due to the superposition of the 006 reflection at the yttrium L 3 and L 2 absorption edges of 2080 eV and 2156 eV, respectively. Tanaka et al. (1997) numerically reproduced the glitches with their custom-made program. The flux at 1385.6 eV is about 80% higher for the (004) reflection due to the added contribution of intensity at 2080 eV from the 006 reflection. We have simulated the anomalous flux enhanced at 1385.6 eV by ray-tracing calculations for the JUMBO beamline at SSRL (Cerino et al., 1980) where the abnormal reflectivity was measured (Wong et al., 1999). Flux measurement at JUMBO was made using a gold mesh detector (Cerino et al., 1980); therefore the quantum efficiency of gold (Krumrey et al., 1988) must be taken into account in the calculation. For creating the YB 66 preprocessor files around 2080 eV it is important to use a dense energy grid. The anomalous dispersion factor ( f 0 , f 00 ) must be sampled correctly, which is guaranteed using Henke data (Henke et al., 1993) from the CXRO website (https://henke.lbl.gov/optical_ constants/sf/y.nff), available in DABAX.
For the JUMBO beamline, there was a Pt-coated mirror at an incidence angle of 89 followed by a DCM of YB 66 (004)    Ray-tracing plots in the OASYS suit for a DCM of InSb (111), using (a) the old and (b) the new format of SHADOW preprocessor files. (c) Peak reflectivity of a single beryl ð10 " 1 10Þ crystal which is a normalized plot between the histogram intensity on the photon energy traced after a beryl crystal and that of the source. and a gold screen detector downstream of the DCM. The calculation parameters are listed in Table 4. The flux is calculated using parameters of the SPEAR storage ring at SSRL (Baltay et al., 1991), for a beam energy of 3 GeV and bending magnetic field of 0.84 T, 0.6 mrad vertical acceptance. The flux at 1385.6 eV is normalized to unity in Table 4. The plots of ray-tracing results by the DCM of YB 66 (004) and YB 66 (006) at 1385.6 eV and 2080 eV, respectively, are shown in Fig. 8. The source bandwidth for source generation in the ray tracing around 1385.6 eV and 2080 eV are chosen to be 0.097% (1385-1386.35 eV) and 0.086% (2079.2-2081 eV), respectively, in order to match the DCM resolution. The obtained ray-tracing intensities are 9220 and 20479 for a source with five million rays.
The photoelectron yield intensity (I) created by photons incident on the gold screen detector is proportional to the product of flux (F), bandwidth (BW) used in ray tracing, mirror reflectivity (R), quantum efficiency (QE) and intensity (WI). WI is found in Fig. 8 and the actual bandwidth (BW) is normalized with the bandwidth (0.1%) used in calculation of the relative flux (F) in Table 4, The yield ratio at the intensities at 1385.6 eV and 2080 eV can be calculated with this equation using data in Table 4 and Fig. 7, thus resulting in I(006) /I(004) = (1.01 Â 0.086% Â 0.59 Â 0.027 Â 20479) / (1.0 Â 0.097% Â 0.77 Â 0.045 Â 9220) = 0.91. This value of 91% increase in flux at 1385.6 eV quantitatively reproduces the anomalous flux glitch (80%) at 1385.6 eV for the DCM of YB 66 (004) reported by Wong et al. (1999).

Summary and conclusions
The use of crystals with high d-spacing in synchrotron radiation monochromators is still a challenge due to the poor quality of most of the suitable crystals. However, improving technology in growing crystals makes it possible to use some of them for tender X-ray monochromators. We extend the current methods of simulating X-ray crystal reflectivity, and perform ray-tracing simulations with crystals constituting charged atoms arranged in any crystalline structure and including isotropic or anisotropic temperature factors. This will open more opportunities for numerical calculations for simulating present or future X-ray monochromators.
We presented examples of X-ray reflectivity for mica, InSb and beryl. Furthermore, we analyzed in detail the YB 66 crystal with a complex structure of 1936 atomic centers. Ray-tracing simulations were performed for a JUMBO monochromator retrieving values consistent with the experimental results. In summary, the tools available in OASYS for crystal reflectivity and ray-tracing crystal monochromators are upgraded to account for any crystal, once the unit cell is known. The new open source software tools developed here are available for supporting accurate calculations in the design and optimization of new X-ray monochromators.
The OASYS workspaces and scripts implementing the simulations presented in this paper are available at https:// github.com/91902078/yb66.

Figure 8
Plots of ray-tracing calculation results with five million rays for the DCM of YB 66 (004) around 1385.6 eV (a) and YB 66 (006) around 2080 eV (b). The input bandwidths around 1385.6 eV and 2080 eV are 0.097% and 0.086%, respectively.